import { SignStatusEnum } from './constant'

export const partyA = [
    {
        required: true,
        message: '请输入甲方',
    },
]

export const agreementType = [
    {
        required: true,
        message: '请选择协议类型',
    },
]

export const agreementCode = [
    {
        required: true,
        message: '请输入协议编码',
    },
]

export const partyAId = [
    {
        required: true,
        message: '请选择甲方',
    },
]

export const partyBId = [
    {
        required: true,
        message: '请选择乙方',
    },
]

export const partyB = [
    {
        required: true,
        message: '请选择乙方',
    },
]

export const agreementName = [
    {
        required: true,
        message: '请输入协议名称',
    },
]

export const contractFileList = [
    {
        required: true,
        trigger: 'change',
        validator: (_rule: any, value: any[], callback: any) => {
            if (!Array.isArray(value) || value.length === 0) {
                callback(new Error('请上传至少一个文件'))
            }
            else {
                const hasFlagTrue = value.some(file => file.unEsign === SignStatusEnum.yes.value)
                if (!hasFlagTrue) {
                    // callback(new Error('至少有一个文件已签章'))
                }
                else {
                    callback()
                }
            }
            callback()
        },
    },
]

export const contractFileListWithSign = [
    {
        required: true,
        trigger: 'change',
        validator: (_rule: any, value: any[], callback: any) => {
            if (!Array.isArray(value) || value.length === 0) {
                callback(new Error('请上传至少一个文件'))
            }
            else {
                const hasFlagTrue = value.every(file => file.unEsign === SignStatusEnum.yes.value)
                if (!hasFlagTrue) {
                    callback(new Error('请将所有文件签章'))
                }
                else {
                    callback()
                }
            }
            callback()
        },
    },
]
